// 禁止长按调用系统
// window.addEventListener('contextmenu', function(e){  
//     e.preventDefault();  
// });

/****** 分享地址 ******/
var shareUrl=''

/****** 控制变量 ******/
var apiFirst=true;      //第一次进入
var isMobile=1;         //是否移动端,默认1是 

/* 解决安卓部分手机样式尺寸问题 */ 
window.onload=function(){
  var a = parseFloat(window.getComputedStyle(document.getElementsByTagName('html')[0],null).fontSize);
  var b = parseFloat(document.getElementsByTagName('html')[0].style.fontSize);
  if(a!=b){
    var bl = a/b
    document.getElementsByTagName('html')[0].style.fontSize = b/bl +"px";
  }
}



// 获取地址栏
function _getParames(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
function getParames(name) {
    // console.log(location)
    var after = window.location.hash.split("?")[1];
    if(after){
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = after.match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }
}

// 遍历删除
// function listRemove(_arr,obj,val){
//     for (var i = 0; i < _arr.length; i++) {
//         if (_arr[i].obj == val){
//             _arr.splice(i, 1);
//         }
//     }
// };

function bodyHidden(){
    document.body.style.overflow='hidden';
}
function bodyAuto(){
    document.body.style.overflow='auto';
}

function touchDefault(event){
    event.preventDefault();	
}
//禁用手机默认的触屏滚动行为
function touchFalse(){
    document.addEventListener('touchmove',touchDefault, { passive: false });
}
//恢复手机默认的触屏滚动行为
function touchTrue(){
    document.removeEventListener('touchmove',touchDefault, { passive: false });
}


var Dpr = 1, uAgent = window.navigator.userAgent;
var isIOS = uAgent.match(/iphone/i);
var isYIXIN = uAgent.match(/yixin/i);
var is2345 = uAgent.match(/Mb2345/i);
var ishaosou = uAgent.match(/mso_app/i);
var isSogou = uAgent.match(/sogoumobilebrowser/ig);
var isLiebao = uAgent.match(/liebaofast/i);
var isGnbr = uAgent.match(/GNBR/i);
function resizeRoot(){
    var wWidth = (screen.width > 0) ? (window.innerWidth >= screen.width || window.innerWidth == 0) ? screen.width : window.innerWidth : window.innerWidth, wDpr, wFsize;
    var wHeight = (screen.height > 0) ? (window.innerHeight >= screen.height || window.innerHeight == 0) ? screen.height : window.innerHeight : window.innerHeight;
    if (window.devicePixelRatio) {
        wDpr = window.devicePixelRatio;
    } else {
        wDpr = isIOS ? wWidth > 818 ? 3 : wWidth > 480 ? 2 : 1 : 1;
    }
    if(isIOS) {
        wWidth = screen.width;
        wHeight = screen.height;
    }
    if(window.orientation==90||window.orientation==-90){
        wWidth = wHeight;
    }else if((window.orientation==180||window.orientation==0)){
    }
    if(wWidth > wHeight){
        wWidth = wHeight;
    }
    wFsize = wWidth > 1080 ? 144 : wWidth / 7.5;
    wFsize = wFsize > 20 ? wFsize : 20;
    window.screenWidth_ = wWidth;
    if(isYIXIN || is2345 || ishaosou || isSogou || isLiebao || isGnbr){//YIXIN 和 2345 这里有个刚调用系统浏览器时候的bug，需要一点延迟来获取
        setTimeout(function(){
            wWidth = (screen.width > 0) ? (window.innerWidth >= screen.width || window.innerWidth == 0) ? screen.width : window.innerWidth : window.innerWidth;
            wHeight = (screen.height > 0) ? (window.innerHeight >= screen.height || window.innerHeight == 0) ? screen.height : window.innerHeight : window.innerHeight;
            wFsize = wWidth > 1080 ? 144 : wWidth / 7.5;
            wFsize = wFsize > 20 ? wFsize : 20;
            // document.getElementsByTagName('html')[0].dataset.dpr = wDpr;
            document.getElementsByTagName('html')[0].style.fontSize = wFsize + 'px';
            document.getElementById("fixed").style.display="none";
        },500);
    }else{
        // document.getElementsByTagName('html')[0].dataset.dpr = wDpr;
        document.getElementsByTagName('html')[0].style.fontSize = wFsize + 'px';
//	                document.getElementById("fixed").style.display="none";
    }

    if(/(iPad)/i.test(uAgent)){
        var head=document.getElementsByTagName("head");
        var viewport=document.createElement("meta");
        viewport.name="viewport";
        viewport.content="target-densitydpi=device-dpi, width="+wWidth+"px, user-scalable=no";
        head.length>0&&head[head.length-1].appendChild(viewport);
    }
    // alert("fz="+wFsize+";dpr="+window.devicePixelRatio+";UA="+uAgent+";width="+wWidth+";sw="+screen.width+";wiw="+window.innerWidth+";wsw="+window.screen.width+window.screen.availWidth);
}
resizeRoot();
